const fs = require('fs')
const js = require('../input/lan')

const path = './locales/com.cn.json'

function writeFile () {
  console.time()
  fs.writeFile(path, JSON.stringify(js), (err) => {
    if (err) {
      return console.warn('写入失败呀呀呀呀'+err)
    }
    console.info('咔咔咔.... 写入成功~')
    console.timeEnd()
  })
}
fs.stat(path, (err) => {
  if (err) {
    console.log('文件不存在')
    fs.mkdir('locales' , () => {
      writeFile()
    })
  } else {
    fs.rmSync(path)
    writeFile()
  }
})
